package com.baidu.service.impl;

import com.baidu.dao.TicketMapper;
import com.baidu.pojo.Ticket;
import com.baidu.service.TicketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class TicketServiceImpl implements TicketService {
    @Autowired
    private TicketMapper ticketMapper;
    @Override
    public List<Ticket> getAllTicket2(Integer eid) {
        return ticketMapper.getAllTicket2(eid);
    }

    //添加门票
    public void addTicket(Ticket ticket){
        ticketMapper.addTicket(ticket);
    }

    //根据id修改门票信息
    public void updateTicket(Ticket ticket){
        ticketMapper.updateTicket(ticket);
    }

    //删除门票
    public void deleteTicket(Integer tid){
        ticketMapper.deleteTicket(tid);
    }

    //查询所有门票
    public List<Ticket> getAllTicket(){
        return ticketMapper.getAllTicket();
    }

    //分页查询所有用户信息,以及关联的角色信息 第一个参数表示起始位置，第二个参数表示页面容量
    public List<Ticket> getByPage(Integer currentPage,Integer pageSize){
        //计算起始位置
        int start=(currentPage-1)*pageSize;

        //执行分页查询
        List<Ticket> list=ticketMapper.getByPage(start,pageSize);

        return list;
    }

    //分页查询总记录数
    public int count() {

        System.out.println("测试");
        return ticketMapper.count();
    }

    //根据id查询指定的用户信息
    public  Ticket getTicketByEid(Integer eid) {
        return ticketMapper.getTicketByEid(eid);
    }

    //根据id查询指定的门票信息
    public  Ticket getTicketByTid(Integer tid){
        return ticketMapper.getTicketByTid(tid);
    }
}
